'use strict';
function curry(fn) {
  /**
   * @param {Function} Slice
   * @param {Function} arguments -> fn
   */
  let Slice = [].slice;

  // star !!!!!
  // arguments -> array, 1 is send to slice
  let args = Slice.call(arguments, 1);
  console.log(args);
  return function () {
    let addArgs = Slice.call(arguments),
        allArgs = args.concat(addArgs);
    return fn.apply(null, allArgs);
  }
}

function add(num1, num2) {
  return num1 + num2;
}

function add5(num) {
  return add(5, num);
}

console.log(add(1, 2));

console.log(add5(6));

add5 = curry(add, 5);

console.log(add5(7));

let add7and8 = curry(add, 7, 8);
console.log(add7and8());

{
  console.log('> Array.reduce\n');
  let sum = [0, 1, 2.3, 3.5, 5].reduce((s, b) => {

    console.log(s, b);
    // return s + b
  });
}